
#include "DWorld.h"
#include "../GlobalGameData.h"

using namespace DeepClasses;

DeepClasses::DWorld::DWorld()
{

}

DeepClasses::DWorld::~DWorld()
{
	BOOST_FOREACH(DMaterial* i, m_pMats)
	{
		if(i!=NULL)
			delete i;
	}
}

int DeepClasses::DWorld::CreateWorld()
{
	gameData.m_world = this;



	m_pMats.push_back(new DMatStone(L"granite", L"stone", 'S',0x06));
	m_pMats.push_back(new DMatStone(L"marble", L"stone", 'S',0x7f));

	m_map.GenerateMap(50,250,250,&m_pMats);

	DDwarf* d = new DDwarf(L"dwarf_1",1,0x04);
	d->Place(TLocation(10,10,30));

	for(int i=8;i<16;i++)
	{
		DCell* cell = m_map.GetCellAt(TLocation(i,15,25));
		cell->m_fillMat = m_pMats.front();
		int x=1;
	}
	m_dwarves.push_back(d);

	DItem* i = new DItem(L"apple", 'A', 0x2a);
	i->m_isFood=true;
	i->Place(TLocation(20,20,25));
	
	m_items.push_back(i);
	
	return DE_OK;
}